import React from 'react'
//1. 导入 store
import store from '../../redux/store'
import Show from './Show';
import Control from './Control';
import { zanIncreAction, zanDecreAction } from '../../redux/reducers/zanReducer';
export default function ReduxCom() {
  //声明函数
  const zanIncre = () => {
    store.dispatch(zanIncreAction(1));
  }

  const zanDecre = () => {
    store.dispatch(zanDecreAction(1));
  }

  return (
    <div className='container'>
      <Show  />
      <hr />
      <Control  />
      <hr />

      <h3>当前的点赞数: {store.getState().zan.value}</h3>
      <button className="btn btn-primary" onClick={zanIncre}>增加</button>&nbsp;
      <button className='btn btn-danger' onClick={zanDecre}>减少</button>
    </div>
  )
}
